import request from '@/common/vmeitime-http';

//搜索楼盘
export function searchFAQProduct(info){
    return request.request({
        url: `/product/mall/qa/v2/query?query=${info.keyword}&city=${info.cityCode}`
    })
}

//获取问答类型标签
export function getForumTags(cityCode=310100){
    return request.request({
        url: `/product/mall/qa/v2/tags?city=${cityCode}`
    })
}

/**
 * 创建问答
 *@param product {String} 楼盘ID
 @param content {String} 内容
 @param tag {String} 标签
 @param city_code {String} 城市id
 @param anonymous {boolean} 匿名 (已废弃)
 */
export function createFAQ(data){
    return request.request({
        url: `/product/mall/qa/v2/create`,
        method: 'post',
        data
    })
}

/**
 * 问答弹幕精选问答
 * */
export function chosenFAQList(cityCode){
    return request.request({
        url: `/product/mall/qa/v2/dm?city=${cityCode}`
    })
}

/**
 * 获取问答列表
 * @param url {String} 请求地址
 * */
export function getFaqList(url){
  return request.request({
      url
  })
}

//问答点赞
export function FAQThumbsUp(questionId){
    return request.request({
        url: `/product/mall/qa/v2/love/${questionId}`,
        method: 'post'
    })
}

//问答收藏
export function FAQCollect(questionId){
    return request.request({
        url: `/product/mall/qa/v2/collect/${questionId}`,
        method: 'post'
    })
}

/**
 * 回复问题
 * @param questionId {Number} 问题ID
 * @param anonymous {Boolean} 是否匿名(已废弃)
 * @param content {String} 内容
 */
export function replyQuestion(data){
    return request.request({
        url: `/product/mall/qa/v2/reply/${data.questionId}`,
        method: 'post',
        data
    })
}

//获取问答详情
export function questionDetail(questionId){
    return request.request({
        url: `/product/mall/qa/v2/detail/${questionId}`
    })
}

//直播精选分类tags
export function liveVideoTags(cityCode){
  return request.request({
    url: `/product/mall/channels/tags?city=${cityCode}`
  })
}

//直播精选视频列表
export function liveVideos(info){
  return request.request({
    url: `/product/mall/channels/list?city=${info.cityCode}&query=${info.param}`
  })
}

//直播视频点赞
export function thumbVideo(videoId){
  return request.request({
    url: `/product/mall/channels/love/${videoId}`,
    method: 'post'
  })
}

//论坛购房百科顶部分类
export function wikiTopData(cityCode){
  return request.request({
    url: `/product/mall/wiki/top?city=${cityCode}`
  })
}

//直播精选视频预览量
export function liveVideoPreview(videoId){
  return request.request({
    url: `/product/mall/channels/view/${videoId}`,
    method: 'post'
  })
}

//删除自己的问答
export function deleteOwnerFAQ(questionId){
  return request.request({
    url: `/product/mall/qa/v2/delete/${questionId}`,
    method: 'delete'
  })
}

/**
 * 用户点击置业顾问的回答跳转楼盘前被锁定
 * @param uid
 * @param product_id 楼盘id
 */
export function adviserLockUser(data){
  return request.request({
    url: `/product/mall/v6/follow2`,
    method: 'post',
    data
  })
}

//加载问答内的评论列表
export function loadFaqCommentList(url){
  return request.request({
    url
  })
}